package com.ayq.activiti.manager.controller;


import com.ayq.activiti.common.util.Ret;
import com.ayq.activiti.manager.domain.activitimanager.service.IActivitiManagerService;
import com.ayq.activiti.manager.dto.ActivitiManagerDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 *
 * <p>流程管理中心</p>
 * @Author ayq
 * @Date 2021/3/29 13:21
 */
@Controller
@RequestMapping("/activiti-manager")
@Api(tags = "流程管理中心")
@Slf4j
public class ActivitiManagerController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ActivitiManagerController.class);

    @Autowired
    private IActivitiManagerService activitiManagerService;


    @GetMapping("/list")
    public String getList(){
        return "model/addactivitimanager";
    }


    /**
     * <p>绑定流程</p>
     * <p>方法名:addActivitiManager</p>
     * @Author ayq
     * @Date 2021/3/31 9:50
     * @Param [activitiManagerDTO]
     * @Return org.ezca.esign.common.base.Ret
     */
    @PostMapping("/addActivitiManager")
    @ApiOperation(value = "绑定流程,生成审核人分配表", notes = "绑定流程，生成审核人分配表")
    @ResponseBody
    public Ret addActivitiManager(@RequestBody ActivitiManagerDTO activitiManagerDTO){
        try {
            activitiManagerService.addActivitiManager(activitiManagerDTO);
            return Ret.ok("绑定流程成功");
        } catch (Exception e) {
            LOGGER.error("绑定流程异常",e);
            return Ret.error("绑定流程异常");
        }
    }
}
